layui.use(['form', 'jquery', 'layer', 'table', 'laydate', 'laypage'], function() {
	var form = layui.form;
	var $ = layui.$;
	var table = layui.table;
	var layer = layui.layer;
	var laydate = layui.laydate;
	var laypage = layui.laypage;
	var select_goods_info = new Array();
	var order_price = 0;
	var citys = '',
		address = '';
	// 处理商品
	var goods_table_filter = 'goods_list',
		goods_form_filter = 'goods_search_form',
		select_goods_table_filter = 'select_goods_list',
		select_goods_form_filter = 'select_goods_search_form';
	// 处理商品选择缓存
	var select_cache = function(obj) {
		var new_json = new Array(),
			have_flag = 1,
			tr = $('div[lay-id="goods_list"]').find('div.layui-table-body').find('table tbody').find(
				'tr td[data-field="goods_sku"][data-val="' + obj.goods_sku + '"]').parent('tr');
		for (var i in select_goods_info) {
			var e = select_goods_info[i];
			if (obj.goods_sku == e.goods_sku) {
				switch (obj.field) {
					case 'num':
						select_goods_info[i].num = obj.value;
						tr.find('td[data-field="' + obj.field + '"]').attr('data-val', obj.value);
						tr.find('td[data-field="' + obj.field + '"]').find('div').text(obj.value);
						break;
					case 'sale_attr_html':
						select_goods_info[i].sale_attr_html = obj.value;
						tr.find('td[data-field="sale_attr"]').find('div').find('span').text(obj.value);
						break;
					case 'sale_attr':
						select_goods_info[i].sale_attr = obj.value;
						break;
					case 'sale_price':
						select_goods_info[i].sale_price = obj.value;
						tr.find('td[data-field="' + obj.field + '"]').attr('data-val', obj.value);
						tr.find('td[data-field="' + obj.field + '"]').find('div').text(obj.value);
						break;
					default:
						// 删除
						select_goods_info.splice(i, 1);
						break;
				}
				have_flag = 0;
			}
		}
		if (have_flag == 1) {
			// 存在标志，不存在 添加;
			select_goods_info.push(obj);
		}
		order_price = 0;
		for (var i in select_goods_info) {
			var e = select_goods_info[i];
			if (e.sale_price != undefined) {
				order_price = order_price + (e.num * e.sale_price * 100);
			}
		}
		$('form[lay-filter="tpl_order"]').find('#order_price').html(abs(order_price));
	}
	// 已选择的商品编号
	var goods_skus_input = $('form[lay-filter="tpl_order"]').find('input[name="goods_skus"]');
	// 已选择
	table.render({
		elem: '#' + goods_table_filter,
		id: goods_table_filter,
		url: goods_list_url,
		method: 'post',
		where: {
			_o: 'goods_id',
			_b: 'desc',
			/* sale_state: 1,
			audit_state: 1, */
			select_goods_skus: goods_skus_input.val(),
			no_more_price: 'yes',
			no_need_picture: 'yes',
			pre_info: 'jun'
		},
		cols: [goods_cols],
		autoSort: false,
		toolbar: '#goodsToolbar',
		defaultToolbar: [],
		done: function(res, curr, count) {
			for (var i in res.data) {
				var e = res.data[i],
					flag = 0;
				for (var j in select_goods_info) {
					var e1 = select_goods_info[j];
					if (e.goods_sku == e1.goods_sku) {
						flag = 1;
					}
				}
				if (flag == 0) {
					if (e.sale_attr == undefined) {
						var temp = {
							goods_sku: e.goods_sku,
							sale_price: e.sale_price,
							num: 1,
							sale_attr_html: '默认属性',
							sale_attr: ''
						};
					} else {
						if (e.sale_attr.length == 0) {
							var temp = {
								goods_sku: e.goods_sku,
								sale_price: e.sale_price,
								num: 1,
								sale_attr_html: '默认属性',
								sale_attr: ''
							};
						} else {
							var temp = {
								goods_sku: e.goods_sku,
								sale_price: e.sale_price,
								num: 1,
								sale_attr_html: '请选择',
								sale_attr: ''
							};
						}
					}
					select_cache(temp);
				}
			}
			// 选择销售属性
			$('div[lay-id="goods_list"]').on('click', '.select-sale-attr', function() {
				var goods_sku = $(this).parents('tr').find('td[data-field="goods_sku"]')
					.attr('data-val'),
					sale_price_html = $(this).parents('tr').find(
						'td[data-field="sale_price"]'),
					sale_attr,
					sale_attr_text = $(this).text().split('+'),
					obj = $(this);
				for (var i in res.data) {
					var e = res.data[i];
					if (e.goods_sku == goods_sku) {
						sale_attr = e.sale_attr;
						sale_price_info = e.sale_price_info;
						break;
					}
				}
				// 构建销售属性页面
				var create_sale_html = function(sale_attr_info, value) {
					var temp = sale_attr_info.sale_attr_value.split(','),
						input_html = '';
					for (var i in temp) {
						var e = temp[i];
						if (e == value) {
							input_html = input_html + '<input type="radio" name="' +
								sale_attr_info.sale_attr_name + '" checked value="' +
								e + '" title="' + e + '">';
						} else {
							input_html = input_html + '<input type="radio" name="' +
								sale_attr_info.sale_attr_name + '"  value="' + e +
								'" title="' + e + '">';
						}
					}
					var html = '<div class="layui-form-item">' +
						'<label class="layui-form-label">' + sale_attr_info
						.sale_attr_name + '</label>' +
						'<div class="layui-input-inline" style="width: 500px;">' +
						input_html +
						'</div></div>';
					return html;
				}
				$('#select_sale_attr form').html('');
				for (var i in sale_attr) {
					var e = sale_attr[i],
						html = create_sale_html(e, sale_attr_text[i]);
					$('#select_sale_attr form').append(html);
				}
				form.render('radio');
				layer.open({
					content: $('#select_sale_attr'),
					type: 1,
					anim: 2,
					title: '选择属性',
					closeBtn: true,
					shadeClose: true,
					area: '800px',
					shade: 0.1,
					btn: ['确定选择'],
					yes: function(index, layero) {
						var sale_attr_html = '',
							sale_attr_price = '';
						for (var i in sale_attr) {
							var e = sale_attr[i],
								value = $('input[name="' + e.sale_attr_name +
									'"]:checked').val();
							if (value == undefined || value == '') {
								layer.msg('请选择' + e.sale_attr_name + '属性', {
									icon: 2,
									anim: 6
								});
								return false;
							}
							sale_attr_html = sale_attr_html == '' ? value :
								sale_attr_html + '+' + value;
							if (e.is_sale_price == 1) {
								sale_attr_price = sale_attr_price == '' ?
									value : sale_attr_price + '+' + value;
							}
						}
						var temp = {
							goods_sku: goods_sku,
							field: 'sale_attr_html',
							value: sale_attr_html
						};
						select_cache(temp);
						var temp = {
							goods_sku: goods_sku,
							field: 'sale_attr',
							value: sale_attr_price
						};
						select_cache(temp);
						// 重置价格
						if (sale_attr_price != '') {
							var sale_price = 0;
							for (var i in sale_price_info.data) {
								var e = sale_price_info.data[i];
								if (e.sale_attr_price_name == sale_attr_price) {
									sale_price = e.sale_price;
									break;
								}
							}
							var temp = {
								goods_sku: goods_sku,
								field: 'sale_price',
								value: sale_price
							};
							select_cache(temp);

						}
						layer.closeAll('page');
					}
				})

			})
			// 选择销售属性结束
			// 赋值
			var tr = $('div[lay-id="goods_list"] div.layui-table-body table tbody tr');
			tr.each(function() {
				for (var i in select_goods_info) {
					var e = select_goods_info[i];
					if ($(this).find('td[data-field="goods_sku"]').attr('data-val') == e
						.goods_sku) {
						$(this).find('td[data-field="sale_price"]').attr('data-val', e
							.sale_price);
						$(this).find('td[data-field="num"]').attr('data-val', e.num);
						$(this).find('td[data-field="sale_price"]').find('div').html(e
							.sale_price);
						$(this).find('td[data-field="num"]').find('div').html(e.num);
						if (e.sale_attr_html != '') {
							$(this).find('td[data-field="sale_attr"]').find('div span')
								.html(e.sale_attr_html);
						}
					}
				}
			})

		}
	});
	// 未选择
	table.render({
		elem: '#' + select_goods_table_filter,
		id: select_goods_table_filter,
		url: goods_list_url,
		mothod: 'post',
		where: {
			_o: 'goods_id',
			_b: 'desc',
			/* sale_state: 1,
			audit_state: 1, */
			no_select_goods_skus: goods_skus_input.val(),
			no_more_price: 'yes',
			no_need_picture: 'yes',
			pre_info: 'jun'
		},
		cols: [select_goods_cols],
		autoSort: false,
		initSort: {
			'field': 'goods_id',
			'type': 'desc'
		},
		height: 'full-200',
		page: {
			layout: ['count', 'first', 'prev', 'page', 'next', 'last', 'skip'],
			limit: 15,
			theme: '#393d49',
			groups: 8
		}
	})
	// 监听点击
	table.on('row(' + select_goods_table_filter + ')', function(obj) {
		var goods_sku = obj.data.goods_sku,
			get_goods_skus_form = $('form[lay-filter="tpl_order"]').find('input[name="goods_skus"]');
		if (get_goods_skus_form.val() == '') {
			get_goods_skus_form.val(goods_sku);
		} else {
			get_goods_skus_form.val(get_goods_skus_form.val() + ',' + goods_sku);
		}
		table.reload(goods_table_filter, {
			where: {
				select_goods_skus: goods_skus_input.val()
			}
		});
		obj.del();
	})
	table.on('toolbar(' + goods_table_filter + ')', function(obj) {
		switch (obj.event) {
			case 'addGoodsToCart':
				get_goods_category(0, 'category_search1', goods_form_value.category_sign1);
				// 会员选择处理结束
				layer.open({
					content: $('#select_goods'),
					type: 1,
					anim: 2,
					title: '选择商品',
					closeBtn: true,
					shadeClose: true,
					area: '85%',
					shade: 0.1
				});

				break;
		}
		return false;
	})
	table.on('tool(' + goods_table_filter + ')', function(obj) {
		var data = obj.data,
			goods_skus = $('form[lay-filter="tpl_order"]').find('input[name="goods_skus"]').val().split(
				',');

		switch (obj.event) {
			case 'remove':
				var temp = {
					goods_sku: data.goods_sku
				};
				var where = new Array();
				for (var i in goods_skus) {
					if (goods_skus[i] != data.goods_sku) {
						where.push(goods_skus[i]);
					}
				}
				var input_value = where.join(',');
				$('form[lay-filter="tpl_order"]').find('input[name="goods_skus"]').val(input_value);
				obj.del();
				select_cache(temp);
				table.reload(select_goods_table_filter, {
					where: {
						no_select_goods_skus: input_value
					}
				});
				break;
			default:
				break;
		}
	})
	// 监听商品修改价格和数量
	table.on('edit(' + goods_table_filter + ')', function(obj) {
		var field = obj.field,
			value = obj.value,
			num_value = 1,
			tr = obj.tr;
		if (tr.find('td[data-field="' + field + '"]').attr('data-val') != '') {
			num_value = tr.find('td[data-field="' + field + '"]').attr('data-val');
		}
		if (field == 'num') {
			var reg = /^\d+$/;
			if (!reg.test(value) || value <= 0) {
				layer.msg('数量格式错误', {
					icon: 2
				});
				tr.find('td[data-field="' + field + '"]').html(
					'<div class="layui-table-cell laytable-cell-' + tr.find('td[data-field="' +
						field + '"]').attr('data-key') + '">' + num_value + '</div>');
				return false;
			}
		} else {
			var reg = /^\d+(\.\d+)?$/;
			if (!reg.test(value)) {
				layer.msg('金额格式错误', {
					icon: 2
				});
				tr.find('td[data-field="' + field + '"]').html(
					'<div class="layui-table-cell laytable-cell-' + tr.find('td[data-field="' +
						field + '"]').attr('data-key') + '">' + num_value + '</div>');
				return false;
			}
		}
		var temp = {
			goods_sku: obj.data.goods_sku,
			field: field,
			value: value
		};
		select_cache(temp);
	});
	// 处理选择会员
	var member_table_filter = 'member_list',
		member_form_filter = 'member_search_form';
	// 获取会员收件地址信息
	var get_shopping = function(member_id) {
		send_info(shopping_list_url, {
			member_id: member_id,
			limit: 1,
			is_default:1
		}, function(data) {
			var ul = $('form[lay-filter="tpl_order"]').find('#shopping_list');
			ul.html('');
			for (var i in data.data) {
				var e = data.data[i];
				var is_default = e.is_default == 1 ? 'checked' : '';
				ul.append('<div><input type="radio" value="' + e.shopping_id + '" ' + is_default +
					' name="shopping_id" lay-skin="primary" title="' + e.province_name + ' ' + e
					.city_name + ' ' + e.area_name + ' ' + e.street + ' （' + e.contacts +
					' 收）<span class=phone>' + e.phone + '</span>" /></div>');
				citys = e.province_name+'·' + e.city_name+'·' + e.area_name;
				address = e.street;
			}
			form.render('radio');
		})
	}
	send_info = function(string_uri, json_data, fun_callback) {
		layer.load(2);
		$.ajax({
			type: "post",
			url: string_uri,
			async: true,
			data: json_data,
			dataType: 'json',
			success: function(data) {
				layer.closeAll('loading');
				if (data['code'] == -101) {
					location.href = 'login.html';
					return false;
				} else if (data['code'] == -200) {
					layer.msg(data['msg'], {
						icon: 2,
						anim: 6
					});
					return false;
				} else if (data['code'] == 0 && data['msg'] == '参数错误') {
					layer.msg('参数错误', {
						icon: 2,
						anim: 6
					});
				} else {
					return fun_callback(data);
				}
			},
			error: function(xhr, type, errorThrown) {
				layer.msg('请求失败，访问地址：' + string_uri, {
					icon: 2,
					anim: 6
				});
				layer.closeAll('loading');
			}
		});
	};
	// 渲染表格
	table.render({
		elem: '#' + member_table_filter,
		id: member_table_filter,
		url: member_list_url,
		method: 'post',
		height: 'full-200',
		where: {
			_o: 'member_id',
			_b: 'asc'
		},
		cols: [member_cols],
		page: {
			layout: ['count', 'first', 'prev', 'page', 'next', 'last', 'skip'],
			limit: 30,
			theme: '#393d49',
			groups: 8
		}
	});
	// 表单input 查询
	$('form[lay-filter="' + member_form_filter + '"]').on('input propertychange', 'input[type="text"]',
		function() {
			if ($(this).prop('comStart')) return;
			var value = $(this).val();
			var name = $(this).attr('name');
			var where = {};
			where[name] = value;
			table.reload(member_table_filter, {
				where: where
			});
		}).on('compositionstart', 'input[type="text"]', function() {
		$(this).prop('comStart', true);
	}).on('compositionend', 'input[type="text"]', function() {
		$(this).prop('comStart', false);
		$(this).trigger('input');
	});
	// 监听点击事件
	table.on('row(' + member_table_filter + ')', function(obj) {
		var member_id = obj.data.member_id,
			member_name = obj.data.username;
		$('form[lay-filter="tpl_order"]').find('input[name="member_id"]').val(member_id);
		$('form[lay-filter="tpl_order"]').find('input[name="member_name"]').val(member_name);
		get_shopping(member_id);
		layer.closeAll('page');
	})
	// 会员选择处理结束
	$('form[lay-filter="tpl_order"]').on('click', 'input[name="member_name"]', function() {
		layer.open({
			content: $('#select_member'),
			type: 1,
			anim: 2,
			title: '选择会员',
			closeBtn: true,
			shadeClose: true,
			area: '85%',
			shade: 0.1
		})
	})
	// 交货日期
	var now = new Date(); //今天
	var tomo = new Date((now / 1000 + 86400 * 2) * 1000); //明天
	laydate.render({
		elem: 'input[name="delivery_date"]',
		min: +2,
		value: tomo
	});
	// 初始化城市
	var initSelectEvent = function(obj) {
		var province = obj["province"],
			city = obj["city"],
			area = obj["district"];
		var province_ul = $('form[lay-filter="tpl_shopping"]').find('select[name="province"]');
		province_ul.html('<option value="">请选择省份</option>');
		for (var i in province) {
			var e = province[i];
			province_ul.append('<option value="' + e.name + '" data-name="'+e.name+'" data-id="'+e.id+'">' + e.name + '</option>');
		}
		// 选择城市
		form.render('select');
		form.on('select(province)', function(data) {
			var getIds = $('select[name="province"] option').map(function() {
				if(data.value == $(this).attr('data-name')){
					return $(this).attr('data-id');
				}
			}).get();
			var city_id = getIds[0]
			
			var city_list = city[city_id];
			var city_ul = $('form[lay-filter="tpl_shopping"]').find('select[name="city"]');
			city_ul.html('<option value="">请选择</option>');
			for (var i in city_list) {
				var e = city_list[i];
				city_ul.append('<option value="' + e.name + '" data-name="'+e.name+'" data-id="'+e.id+'">' + e.name + '</option>');
			}
			form.render('select');
		});
		form.on('select(city)', function(data) {
			var getIds = $('select[name="city"] option').map(function() {
				if(data.value == $(this).attr('data-name')){
					return $(this).attr('data-id');
				}
			}).get();
			var area_id = getIds[0]
			
			var area_list = area[area_id];
			var area_ul = $('form[lay-filter="tpl_shopping"]').find('select[name="area"]');
			area_ul.html('<option value="">请选择</option>');
			for (var i in area_list) {
				var e = area_list[i];
				area_ul.append('<option value="' + e.name + '">' + e.name + '</option>');
			}
			form.render('select');
		})
	}
	var ajaxConfig = {
		url: "/static/js/jqcity/allcity.js",
		dataType: "jsonp",
		jsonpCallback: "callback",
		success: initSelectEvent
	}
	$.ajax(ajaxConfig);
	form.on('submit(submit_order)', function(data) {
		var field = data.field;
		field.select_goods_info = select_goods_info;
		field.order_money = order_price;
		if (field.shopping_id == undefined || field.shopping_id == '') {
			layer.msg('请填写收货地址', {
				icon: 2,
				anim: 6
			});
			return false;
		}
		if (field.select_goods_info.length == 0) {
			layer.msg('请选择订单商品', {
				icon: 2,
				anim: 6
			});
			return false;
		}
		for (var i in select_goods_info) {
			var e = select_goods_info[i];
			if (e.sale_attr_html == '请选择') {
				layer.msg('请选择商品（' + e.goods_sku + '）属性', {
					icon: 2,
					anim: 6
				});
				return false;
			}
		}
		if (field.is_invoice == '2') {
			if (field.invoice_title == '') {
				layer.msg('请输入发票抬头', {
					icon: 2,
					anim: 6
				});
				return false;
			}
			/*	if (field.invoice_duty == '') {
				layer.msg('请输入发票税号', {
					icon: 2,
					anim: 6
				});
				return false;
			}
		
			if(field.invoice_type == 3){
				if(field.invoice_addr == ''){
					layer.msg('请输入地址',{
						icon:2,
						anim:6
					});
					return false;
				}
				if(field.invoice_tel == ''){
					layer.msg('请输入电话',{
						icon:2,
						anim:6
					});
					return false;
				}
				if(field.invoice_bank == ''){
					layer.msg('请输入开户银行',{
						icon:2,
						anim:6
					});
					return false;
				}
				if(field.invoice_account == ''){
					layer.msg('请输入开户账户',{
						icon:2,
						anim:6
					});
					return false;
				}
			}
			*/
		}
		var url = $('form[lay-filter="tpl_order"').attr('action');
		var param = '{"Cityname":"' + citys + '","address":"'+address+'","payment":' + $('input[name="pay_type"]:checked')
		.val() + ',"remark":"","amount":"'+(order_price/100)+'","danweiguid":"","companyName":"'+$('input[name="invoice_title"]').val()+'","invoiceTaxNo":"'+$('input[name="invoice_duty"]').val()+'","name":"'+$('input[name="contacts"]').val()+'","mobile":"'+$('#phone_addr').val()+'"}';
		field.api_param = param;
		send_info(url, field, function(data) {
			if (data.code == 0) {
				layer.msg('保存成功', {
					icon: 1
				});
				parent.layui.table.reload('order_list');
				parent.layer.closeAll('iframe');

			} else {
				layer.msg(data.msg, {
					icon: 2,
					anim: 6
				});
			}
		});
		return false;
	})
	// 关闭页面
	$('#close_page').on('click', function() {
		parent.layer.closeAll('iframe');
	})
	// 保存收货地址
	form.on('submit(submit_shopping)', function(data) {
		var field = data.field;
		if (field.member_id == '') {
			layer.msg('请先选择会员', {
				icon: 2,
				anim: 6
			});
			return false;
		}
		var url = $('form[lay-filter="tpl_shopping"]').attr('action');
		send_info(url, field, function(data) {
			if (data.code == 0) {
				layer.msg('保存成功', {
					icon: 1
				});
				setTimeout(function() {
					get_shopping(field.member_id);
					layer.closeAll('page');
				}, 1500);
				
			} else {
				layer.msg(data.msg, {
					icon: 2,
					anim: 6
				});
			}
		})
		return false;
	})
	// 新增配送地址
	$('form[lay-filter="tpl_order"]').on('click', '#add_shopping', function() {
		var member_id = $('form[lay-filter="tpl_order"]').find('input[name="member_id"]').val();
		if (member_id == '') {
			layer.msg('请先选择会员', {
				icon: 2,
				anim: 6
			});
			return false;
		}
		layer.open({
			content: $('#shopping'),
			type: 1,
			anim: 2,
			title: '新增配送地址',
			closeBtn: true,
			shadeClose: true,
			area: ['800px', '500px'],
			shade: 0.1
		})
	})
	// 处理开发票信息
	form.on('radio(is_invoice)', function(data) {
		if (data.value == 2) {
			$('#invoice_info').show(300);
		} else {
			$('#invoice_info').hide(300);
		}
	})
	// 监听发票类型
	form.on('radio(invoice_type)', function(data) {
		if (data.value == 3) {
			$('.invoice_type3').show(300);
		} else {
			$('.invoice_type3').hide(300);
		}
	});
	// 商品 查询
	$('form[lay-filter="' + select_goods_form_filter + '"]').on('input propertychange', 'input[type="text"]',
		function() {
			if ($(this).prop('comStart')) return;
			var value = $(this).val();
			var name = $(this).attr('name');
			var where = {};
			where[name] = value;
			table.reload(select_goods_table_filter, {
				where: where
			});
		}).on('compositionstart', 'input[type="text"]', function() {
		$(this).prop('comStart', true);
	}).on('compositionend', 'input[type="text"]', function() {
		$(this).prop('comStart', false);
		$(this).trigger('input');
	});
	var select_search = function(field, value) {
		var where = {};
		where[field] = value;
		table.reload(select_goods_table_filter, {
			where: where
		});
	};
	// 获取品牌
	var get_goods_brand = function(category_sign) {
		var e = $('#brand_sign');
		e.html('');
		e.append('<option value="">加载中...</option>');
		e.prop('disabled', true);
		form.render('select');
		var post_data = {
			is_select: 'yes',
			category_sign: category_sign,
			_o: 'brand_id',
			_b: 'desc',
			page: 1,
			limit: 100
		};
		send_info(brand_select_uri, post_data, function(data) {
			e.html('<option value="">请选择</option>');
			if (data.count > 0) {
				for (var i in data.data) {
					var temp = data.data[i];
					if (goods_form_value.brand_sign == temp.brand_sign) {
						var op_html = '<option selected value="' + temp.brand_sign + '">' + temp
							.brand_name + '</option>';
					} else {
						var op_html = '<option value="' + temp.brand_sign + '">' + temp.brand_name +
							'</option>';
					}
					e.append(op_html);
				}
			};
			e.prop('disabled', false);
			form.render('select');
		})
	};
	var goods_form_value = {
		category_sign1: '',
		category_sign2: '',
		category_sign3: ''
	};
	// 初始化分类
	var get_goods_category = function(parent_sign, filter, value) {
		var e = $('#' + filter);
		e.html('');
		e.append('<option value="">加载中...</option>');
		e.prop('disabled', true);
		var id = e.attr('id');
		form.render('select');
		var post_data = {
			parent_sign: parent_sign,
			audit_state: 1
		}
		send_info(category_select_uri, post_data, function(data) {
			e.html('<option value="">请选择分类</option>');
			for (var i in data.data) {
				var temp = data.data[i];
				if (value == temp.category_sign) {
					var op_html = '<option selected value="' + temp.category_sign + '">' + temp
						.category_name + '</option>';
				} else {
					var op_html = '<option value="' + temp.category_sign + '">' + temp
						.category_name + '</option>';
				}
				e.append(op_html);
			}
			e.prop('disabled', false);
			form.render('select');
			if (value != undefined) {
				if (id == 'category_search1') {
					get_goods_category(value, 'category_search2', goods_form_value.category_sign2);
					$('#category_search3').html('');
					$('#goods_brand_search').html('');
					get_goods_brand(value);
				} else if (id == 'category_search2') {
					get_goods_category(value, 'category_search3', goods_form_value.category_sign3);
					get_goods_brand(value);
				} else {
					get_goods_brand(value);
				}
			}
		})
	}
	var fliter1 = 'category_search1';
	// 分类联动
	form.on('select', function(data) {
		var value = data.value;
		var e = data.elem;
		var id = $(e).attr('id');
		switch (id) {
			case 'category_search1':
				get_goods_category(value, 'category_search2', goods_form_value.category_sign2);
				$('#category_search3').html('');
				$('#brand_sign').html('');
				get_goods_brand(value);
				select_search('category_sign1', value);
				break;
			case 'category_search2':
				get_goods_category(value, 'category_search3', goods_form_value.category_sign3);
				get_goods_brand(value);
				select_search('category_sign2', value);
				break;
			case 'category_search3':
				get_goods_brand(value);
				select_search('category_sign3', value);
				break;
			case 'site_id':
				goods_select_site_id = value;
				select_search('site_id', value);
				break;
			case 'brand_sign':
				select_search('brand_sign', value);
				break;
			default:
				break;
		}
	});

})
